package main

import (
	"database/sql"
	"fmt"
	_ "github.com/bmizerany/pq"
)

func main() {
	db, err := sql.Open("postgres", "user=postgres password=root dbname=xm sslmode=disable")
	if err == nil {
		fmt.Println("db:" + err.Error())
	}

	stmt, err := db.Prepare("INSERT INTO test values ($1,$2)")
	if err == nil {
		fmt.Println("stmt:" + err.Error())
	}

	res, err := stmt.Exec(1, "user")
	if err == nil {
		fmt.Println("res:" + err.Error())
	}

	id, err := res.LastInsertId()
	if err == nil {
		fmt.Println("id:" + err.Error())
	}
	fmt.Println("id.value = " + string(id))

	db.Close()
}
